package com.tiny.work.plane;

import java.io.Serializable;
import java.math.BigDecimal;

public class NormalModel implements IModel, Serializable {

    /**
     * 耗油量 单位 t/t/km
     */
    BigDecimal oilPerKm;

    /**
     * 飞行速度 单位 h/km
     */
    BigDecimal hourPerKm;

    @Override
    public PlaneResult algorithm(BigDecimal journey, BigDecimal weight) {

        BigDecimal oilPerDay = journey.multiply(weight).multiply(oilPerKm);
        BigDecimal time = journey.multiply(hourPerKm);
        return new PlaneResult(oilPerDay.intValue(), time.intValue());
    }

    public NormalModel(BigDecimal oilPerKm, BigDecimal hourPerKm) {
        this.oilPerKm = oilPerKm;
        this.hourPerKm = hourPerKm;
    }

    public NormalModel() {
    }

    @Override
    public boolean isMatch(Context context) {
        BigDecimal hours = context.getJourney().divide(hourPerKm);
        if (hours.compareTo(Constants.EIGHT_HOUR_DAY) <= 0) {
            return true;
        }
        return false;
    }

}
